package androidchat.com.view;

import java.util.Calendar;

public class getdate {
	public getdate(){}
	
	public String datetostring(int i){
		
		Calendar c = Calendar.getInstance(); 
        String month=null,day=null,hour=null,mins=null;
        String year = String.valueOf(c.get(Calendar.YEAR)); 
        if((c.get(Calendar.MONTH)+1)<10)
        	month="0"+String.valueOf(c.get(Calendar.MONTH)+1);
        else
        	month = String.valueOf(c.get(Calendar.MONTH)); 
        if((c.get(Calendar.DAY_OF_MONTH)+1)<10)
        	day="0"+String.valueOf(c.get(Calendar.DAY_OF_MONTH) + 1);
        else
        	day=String.valueOf(c.get(Calendar.DAY_OF_MONTH) + 1); 
        if(c.get(Calendar.HOUR_OF_DAY)<10)
        	hour="0"+String.valueOf(c.get(Calendar.HOUR_OF_DAY));
        else
        	hour=String.valueOf(c.get(Calendar.HOUR_OF_DAY));
        if(c.get(Calendar.MINUTE)<10)
        	mins="0"+String.valueOf(c.get(Calendar.MINUTE));
        else
        	mins=String.valueOf(c.get(Calendar.MINUTE));
        StringBuffer sbBuffer = new StringBuffer(); 
        if(i==1) 
        	sbBuffer.append(year + "-" + month + "-" + day + " " + hour + ":" + mins);  
        else  
        	sbBuffer.append(hour + ":" + mins);  
        	
        return sbBuffer.toString(); 
		
		
		
	}

}
